package com.sdutcm.xuake.xuanke_demo.dao;

import com.sdutcm.xuake.xuanke_demo.bean.Course;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

/**
 * Created with IntelliJ IDEA.
 *
 * @author 小浩
 * @date 2018-09-19 23:28
 * @package com.sdutcm.xuake.xuanke_demo.dao
 * @description
 */
public interface CourseDao extends JpaRepository<Course,Integer> {
    @Modifying
    @Query("update Course set yvLiang=yvLiang-1 where cousreName=:cousreName")
    int decrYvLiang(@Param("cousreName") String cousreName);


    @Modifying
    @Query("update Course set yvLiang=yvLiang+1 where cousreName=:cousreName")
    int incrYvLiang(@Param("cousreName") String cousreName);

    Course findByCousreName(String name);
}
